package com.iss.apartmentmanage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.iss.apartmentmanage.entity.RoomManage;
import com.iss.apartmentmanage.model.BaseModel;
import com.iss.apartmentmanage.model.MyResponseData;
import com.iss.apartmentmanage.service.ConsoleService;
import com.iss.apartmentmanage.service.impl.CheckServiceImpl;
import com.iss.apartmentmanage.service.impl.ConsoleServiceImpl;
import com.iss.apartmentmanage.utils.Create30DayMapUtil;
import com.iss.apartmentmanage.utils.MyJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/console")
public class consoleController {
    @Autowired
    ConsoleServiceImpl service;

    /**
     * 控制层显示的数据
     */
    @RequestMapping(value = "/checkinForDayAndMonth",method = RequestMethod.POST)
    public String checkinForDayAndMonth(){
        MyResponseData myResponseData = new MyResponseData();
            Integer dayCount =service.selectCheckinForDay();
            Integer monthCount=service.selectCheckinForMonth();
            Integer dayMoney=service.selectMoneyForDay();
            Integer monthMoney =service.selectMoneyForMonth();
            Map<String,Integer> map= new HashMap<>();
            map.put("dayCount",dayCount);
            map.put("monthCount",monthCount);
            map.put("dayMoney",dayMoney);
            map.put("monthMoney",monthMoney);
            myResponseData.setErrorCode(1);
            myResponseData.setMsg("成功");
            myResponseData.setObject(map);

            return MyJson.getJson(myResponseData);
    }
    /**
     * 统计折线图
     */
    @RequestMapping(value = "/checkinChart",method = RequestMethod.POST)
    public String checkinChartCount(){
        MyResponseData myResponseData = new MyResponseData();
        List<Map<String, String>> chartCount = service.checkinChartCount();
        List<Map<String, String>> chartMoney = service.checkinChartMoney();
        myResponseData.put("chartCount",chartCount);
        myResponseData.put("chartMoney",chartMoney);
        return MyJson.getJson(myResponseData);
    }

















}
